package com.shine.eventdispense;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import com.shine.eventdispense.view.MyButton;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    private MyButton mButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mButton = (MyButton) findViewById(R.id.btn);
        mButton.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                Log.d(TAG, "onTouch: " + (Math.asin(-0.5) * 180 / Math.PI));

                int action = event.getAction();

                switch (action) {
                    case MotionEvent.ACTION_DOWN:
                        Log.e(TAG, "MyButton onTouch ACTION_DOWN");
                        break;
                    case MotionEvent.ACTION_MOVE:
                        Log.e(TAG, "MyButton onTouch ACTION_MOVE");
                        break;
                    case MotionEvent.ACTION_UP:
                        Log.e(TAG, "MyButton onTouch ACTION_UP");
                        break;
                    default:
                        break;
                }

                return false;
            }
        });

    }
}
